package define

var (
	TokenExpireTime = 3600 * 24 * 3
	TokenSecret     = "trident19891201"

	EmailAddr     = "smtp.163.com"
	EmailPort     = "465"
	EmailUsername = "xxcfasd"
	EmailPassword = "hu19891201"

	UploadImageDomain    = "http://file-changdong-1.img-cn-shanghai.aliyuncs.com/"
	OssEndPoint          = "oss-cn-shanghai.aliyuncs.com"
	OssAccessKeyId       = "LTAIzceaX6PqFgdt"
	OssAccessKeySecret   = "LKK4RZq80qe6rbg82GRCJ1cJ3TCmM2"
	OssBucket            = "file-changdong-1"
	OssChunkSize         = 100 * 1024
	OssDownloadChunkSize = 100 * 1024

	LimiterResource = "request-qps"
	LimiterData     = map[string]interface{}{
		"request-qps": map[string]interface{}{
			"threshold":              100,
			"statIntervalInMs":       1000,
			"tokenCalculateStrategy": 0,
			"controlBehavior":        0,
		},
		"request-interval": map[string]interface{}{
			"threshold":              10000,
			"statIntervalInMs":       1000,
			"tokenCalculateStrategy": 0,
			"controlBehavior":        0,
		},
		"request-millisecond": map[string]interface{}{
			"threshold":              80,
			"statIntervalInMs":       100,
			"tokenCalculateStrategy": 0,
			"controlBehavior":        0,
		},
	}

	CircuitbreakerResource = "request-slow-ratio"
	CircuitbreakerData     = map[string]interface{}{
		"request-slow-ratio": map[string]interface{}{
			"strategy":         0,
			"retryTimeoutMs":   3000,
			"minRequestAmount": 1,
			"statIntervalMs":   10000,
			"maxAllowedRtMs":   5,
			"threshold":        0.1,
		},
		"request-error-ratio": map[string]interface{}{
			"strategy":         1,
			"retryTimeoutMs":   3000,
			"minRequestAmount": 2,
			"statIntervalMs":   10000,
			"maxAllowedRtMs":   5,
			"threshold":        0.5,
		},
		"request-error-count": map[string]interface{}{
			"strategy":         2,
			"retryTimeoutMs":   5000,
			"minRequestAmount": 10,
			"statIntervalMs":   10000,
			"maxAllowedRtMs":   5,
			"threshold":        100,
		},
	}

	IsolationResource  = "request-isolation"
	IsolationThreshold = 12
)

/**
 * 获取全部订单状态
 *
 * @return map[string]interface{}
 * @author huwl
 * @date 2025/10/09 11:13:31
 */
func GetAllOrderStatus() []map[string]interface{} {
	return []map[string]interface{}{
		map[string]interface{}{
			"value":     0,
			"value_txt": "待付款",
		},
		map[string]interface{}{
			"value":     1,
			"value_txt": "已付款",
		},
		map[string]interface{}{
			"value":     2,
			"value_txt": "待发货",
		},
		map[string]interface{}{
			"value":     3,
			"value_txt": "已发货",
		},
		map[string]interface{}{
			"value":     4,
			"value_txt": "已揽件",
		},
		map[string]interface{}{
			"value":     5,
			"value_txt": "派件中",
		},
		map[string]interface{}{
			"value":     6,
			"value_txt": "待评价",
		},
		map[string]interface{}{
			"value":     7,
			"value_txt": "已完成",
		},
		map[string]interface{}{
			"value":     8,
			"value_txt": "退款中",
		},
		map[string]interface{}{
			"value":     -1,
			"value_txt": "已取消",
		},
		map[string]interface{}{
			"value":     -2,
			"value_txt": "已退款",
		},
		map[string]interface{}{
			"value":     -3,
			"value_txt": "已部分退款",
		},
		map[string]interface{}{
			"value":     -5,
			"value_txt": "已关闭",
		},
	}
}

/**
 * 获取订单状态
 *
 * @param int status -----------------------必传,订单状态
 * @return map[string]interface{}
 * @author huwl
 * @date 2025/10/09 11:13:31
 */
func GetOrderStatus(status int) map[string]interface{} {
	var orderStatusValue map[string]interface{}
	orderStatusItems := GetAllOrderStatus()
	for _, orderStatusItem := range orderStatusItems {
		if orderStatusItem["value"].(int) == status {
			orderStatusValue = orderStatusItem
			break
		}
	}
	return orderStatusValue
}

/**
 * 获取全部支付渠道
 *
 * @return map[string]interface{}
 * @author huwl
 * @date 2025/10/09 11:13:31
 */
func GetPayChannels() []map[string]interface{} {
	return []map[string]interface{}{
		map[string]interface{}{
			"value":     1,
			"value_txt": "微信",
		},
		map[string]interface{}{
			"value":     2,
			"value_txt": "会员卡",
		},
		map[string]interface{}{
			"value":     3,
			"value_txt": "其他费用抵扣",
		},
		map[string]interface{}{
			"value":     4,
			"value_txt": "支付宝",
		},
		map[string]interface{}{
			"value":     5,
			"value_txt": "其它",
		},
		map[string]interface{}{
			"value":     6,
			"value_txt": "现金余额",
		},
	}
}

/**
 * 获取支付渠道
 *
 * @param int payChannel -------------------必传,支付渠道
 * @return map[string]interface{}
 * @author huwl
 * @date 2025/10/09 11:13:31
 */
func GetPayChannel(payChannel int) map[string]interface{} {
	var payChannelValue map[string]interface{}
	payChannelItems := GetPayChannels()
	for _, payChannelItem := range payChannelItems {
		if payChannelItem["value"].(int) == payChannel {
			payChannelValue = payChannelItem
			break
		}
	}
	return payChannelValue
}

/**
 * 获取全部平台
 *
 * @return map[string]interface{}
 * @author huwl
 * @date 2025/10/09 11:13:31
 */
func GetPlatforms() []map[string]interface{} {
	return []map[string]interface{}{
		map[string]interface{}{
			"value":     1,
			"value_txt": "微信",
		},
		map[string]interface{}{
			"value":     2,
			"value_txt": "Android",
		},
		map[string]interface{}{
			"value":     3,
			"value_txt": "IOS",
		},
		map[string]interface{}{
			"value":     4,
			"value_txt": "PC",
		},
		map[string]interface{}{
			"value":     5,
			"value_txt": "小程序",
		},
	}
}

/**
 * 获取平台
 *
 * @param int platform ---------------------必传,平台
 * @return map[string]interface{}
 * @author huwl
 * @date 2025/10/09 11:13:31
 */
func GetPlatform(platform int) map[string]interface{} {
	var platformValue map[string]interface{}
	platformItems := GetPlatforms()
	for _, platformItem := range platformItems {
		if platformItem["value"].(int) == platform {
			platformValue = platformItem
			break
		}
	}
	return platformValue
}
